//
//  KFDEFTHoldingsViewModel.m
//  KFD
//
//  Created by JIRENTIANXIANG on 6/24/15.
//  Copyright © 2015 kfd. All rights reserved.
//

#import "KFDETFHoldingsViewModel.h"
#import "KFDClient.h"

@implementation KFDETFHoldingsViewModel

-(instancetype)init
{
    if (self=[super init]) {
        self.silverHoldings=[[NSArray alloc] init];
        self.goldHoldings=[[NSArray alloc] init];
    }
    return self;
}

-(void)loadSilverHoldingsWithMaxCount:(NSUInteger)maxCount page:(NSUInteger)page
{
    KFDClient* client=[KFDClient sharedClient];
    [client getETFHoldingsWithTypeId:@"1" maxCount:maxCount page:page successHandler:^(NSArray *holdings) {
        self.silverHoldings=holdings;
        [[NSNotificationCenter defaultCenter] postNotificationName:KFDSilverHoldingsReadyNotification object:nil];
    } failureHandler:^(KFDResponseBody *response) {
        
    }];
}

-(void)loadGoldHoldingsWithMaxCount:(NSUInteger)maxCount page:(NSUInteger)page
{
    KFDClient* client=[KFDClient sharedClient];
    [client getETFHoldingsWithTypeId:@"2" maxCount:maxCount page:page successHandler:^(NSArray *holdings) {
        self.goldHoldings=holdings;
        [[NSNotificationCenter defaultCenter] postNotificationName:KFDGoldHoldingsReadyNotification object:nil];
    } failureHandler:^(KFDResponseBody *response) {
        
    }];
}

@end
